<style>
    /* 根据字数修改 */
    .layui-form-label {
        width: 60px;
    }

    /* .layui-form-item .layui-input-inline{
        width: 240px;
    } */
</style>
<div class="layuimini-container layuimini-page-anim">
    <!-- 用于创建子页面 -->
    <div class="page-create"></div>

    <!-- page-main-create -->
    <!-- 用于显示 隐藏 -->
    <div class="layuimini-main page-main-create">

         <div class="title-row layuimini-title ">
            <div class="title-left">
                <h4><span>人员&工牌绑定</span></h4>
            </div>
            <div class="title-right">
                <span class="title-right-text">
                    请到“基础数据管理-物联设备管理”中进行绑定
                     <button type="button" class="layui-btn  layui-btn-sm layui-btn-primary ml-3"
                        lay-on="download">导出</button>
                </span>
            </div>
        </div>

        <div class="m-df">
            <form class="layui-form" action="" lay-filter="search-form">
                <div class="layui-form-item">
                    <div class="search-box-wrapper">
                        <div class="search-box-body">
                            <div class="layui-inline">
                                <label class="layui-form-label">姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="userName" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>


                            <div class="layui-inline">
                                <label class="layui-form-label">手机号</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="mobile" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备编码</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="facilityTririgaCode" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备状态</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择" name="status"
                                        lay-search >
                                        <option value="1">在线</option>
                                        <option value="2">离线</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">人员编码</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="userTririgaCode" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">供应商</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择" name="projectIds"
                                        lay-search >
                                        <option value="1">北京鑫鑫佳美保洁服务有限公司</option>
                                        <option value="2">北京顺逸城市环境管理有限公司</option>
                                        <option value="3">欣中基清洁服务</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">岗位</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="departmentTririgaCodes" lay-search >
                                        <option value="1">中心管理</option>
                                        <option value="2">中心管理/业务支持部</option>
                                        <option value="3">巡查/安全</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属网格</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="departmentTririgaCodes" lay-search >
                                        <option value="1">中心管理</option>
                                        <option value="2">中心管理/业务支持部</option>
                                        <option value="3">巡查/安全</option>
                                        <option value="4">其他</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="relateFacilityName" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备DID</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="did" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备电量</label>
                                <div class="layui-input-inline">
                                    <div class="pt-5">
                                        <div id="powerScope"></div>
                                        <div class="flex layui-font-12 layui-font-gray mt-3">
                                            <div class="flex-1">0%</div>
                                            <div class="flex-1">20%</div>
                                            <div class="flex-1">40%</div>
                                            <div class="flex-1">60%</div>
                                            <div class="flex-1">80%</div>
                                            <div class="flex-1">100%</div>
                                        </div>
                                    </div>

                                    <!-- <input type="text" placeholder="请输入" name="did" autocomplete="off"
                                    class="layui-input"> -->
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设备类型</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="businessNames" lay-search >
                                        <option value="1">EMP工牌</option>
                                        <option value="2">执法仪</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="search-box-btns">
                            <div class="switch-wrapper" id="toggleFormBtn">
                                <span>展开</span>
                                <i class="layui-icon layui-icon-down" id="toggleIcon"></i>
                            </div>
                            <button type="submit" class="layui-btn layui-btn-sm" lay-submit
                                lay-filter="data-search-btn">查询</button>
                            <button type="reset" class="layui-btn  layui-btn-sm layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="section table-stripe">
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </div>
        <script type="text/html" id="currentTableBar">
            <a class="layui-font-blue mr-3" lay-event="edit">设备详情</a>
            <a class="layui-font-blue mr-3" lay-event="detail">人员轨迹</a>
        </script>
    </div>
</div>
<script>
    layui.use(['form', 'table', 'tabs', 'miniPage', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            tabs = layui.tabs,
            laydate = layui.laydate,
            layer = layui.layer,
            util = layui.util,
            element = layui.element,
            slider = layui.slider,
            miniPage = layui.miniPage;
        /******************** 事件 start ********************/

        util.on('lay-on', {
            //导出
            'download': function () {
                console.log('导出---')
            }
        })
        /******************** 事件 end ********************/


        /******************** 渲染组件 start ********************/
        form.render('select'); //刷新select选择框渲染

        slider.render({
            elem: '#powerScope',
            value: [20, 40],
            range: true,
            step: 20, // 步长
            showstep: true, // 开启间隔点
            change: function (value) {
                console.log(value) // 滑块当前值
                // do something
            }
        });

        /******************** 渲染组件 end ********************/
        console.error('table==', table)
        table.render({
            elem: '#currentTableId',
            url: 'api/table.json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter'],
            cols: [[
                { type: 'numbers', width: 80, title: '序号' },
                { field: 'sign', minWidth: 100, title: "岗位" },
                { field: 'sign', minWidth: 100, title: "职位" },
                { field: 'sign', minWidth: 100, title: "人员编码" },
                { field: 'sign', minWidth: 100, title: "所属供应商" },
                { field: 'sign', minWidth: 100, title: "所属网格" },
                { field: 'sign', minWidth: 100, title: "出勤范围" },
                { field: 'sign', minWidth: 100, title: "人员手机号" },
                { field: 'sign', minWidth: 180, title: "被关联设备名称" },
                { field: 'sign', minWidth: 100, title: "设备类型" },
                { field: 'sign', minWidth: 180, title: "设备TririgaCode" },
                { field: 'sign', minWidth: 100, title: "设备编码" },
                { field: 'sign', minWidth: 100, title: "设备DID" },
                { field: 'sign', minWidth: 100, title: "设备电量" },
                { field: 'sign', minWidth: 100, title: "设备状态" },
                { field: 'time', minWidth: 180, title: "最后一次通讯时间" },
                { title: '操作', fixed: 'right', minWidth: 180, toolbar: '#currentTableBar', align: "center" }
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
size: 'lg'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });




        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                var content = miniPage.getHrefContent('page/workforce/rm/components/deviceDetails.html');
                var openWH = miniPage.getOpenWidthHeight();
                var index = layer.open({
                    title: '设备详情',
                    type: 1,
                    shade: 0.5,
                    maxmin: false,
                    shadeClose: true,
                    area: ['500px'],// 宽度自动，高度固定
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'detail') {  // 监听详情操作
                var content = miniPage.getHrefContent('page/components/trackMap.html');
                var openWH = miniPage.getOpenWidthHeight();
                var index = layer.open({
                    title: '吴征巡查/安全',
                    type: 1,
                    shade: 0.5,
                    maxmin: false,
                    shadeClose: true,
                    success: function (layero, index) {
                        layer.full(index); // 最大化
                    },
                    area: ['100%', openWH[1] + 'px'],
                    content: content,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });

        // 开启监听 折叠展开事件
        miniPage.listen()

    });
</script>